package com.wxf.pokers;

import java.util.Arrays;
public class Poker {
	public static void main(String[] args) {
		int[] cards = new int[54];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = i + 1;
		}
		int[][] players = new int[3][17];
		for (int j = 0; j < players.length; j++) {
			for (int i = 0; i < players[j].length;) {
				int ram = (int) (Math.random() * 54);
				int card = cards[ram];
				if (card >= 0) {
					cards[ram] = -1;
					players[j][i] = card;
					i++;
				}
			}
			System.out.println("Player" + (j + 1) + Arrays.toString(players[j]));
		}
		System.out.print("底牌为：");
		for (int i = 0; i < cards.length; i++) {
			if (cards[i] != -1) {
				System.out.print(cards[i] + ",");
			}
		}
		System.out.println();
		int card = 34;//草花9
		String result = cardinfo(card);
		
		System.out.println("手牌点数为：" + result);
	}
  /**
   *封装通过扑克代码，得到扑克点数和花色的方法 
   *@param card 扑克代码 
   *@return 扑克的花色和点数的字符串表示  
   */
	public static String cardinfo(int card) {
		String result;
		int color = (card - 1) / 13;
		switch (color) {
		case 0:
			result = "黑桃";
			break;
		case 1:
			result = "红桃";
			break;
		case 2:
			result = "梅花";
			break;
		case 3:
			result = "方片";
			break;
		default:
			result = "错误花色代码";
			break;
		}
		
		int point = card % 13;
		switch (point) {
		case 1:
			result += "A";
			break;
		case 11:
			result += "J";
			break;
		case 12:
			result += "Q";
			break;
		case 13:
			result += "K";
			break;
		default:
			result += point + "";
			break;
		}
		return result;
	}
}
